package biblioteca;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UtilidadesBD {
	static private Connection con;
	static private Statement stmt;
	static private ResultSet rs; 
	
	public static void conectar()
  	{
  		try
  		{
  			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  			 con = DriverManager.getConnection("jdbc:odbc:Biblioteca");
  			 setStmt(con.createStatement());
  			
  		}catch( Exception e)
  		{
  			System.out.println(e.getMessage());
  		}
  	}

	public static void setStmt(Statement stmt) {
		UtilidadesBD.stmt = stmt;
	}

	public static Statement getStmt() {
		return stmt;
	}

	public static void setRs(ResultSet rs) {
		UtilidadesBD.rs = rs;
	}

	public static ResultSet getRs() {
		return rs;
	}
	public static void desconectarBD() {
		
		try {
				stmt.close();
				con.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}

	}
}
